﻿@using MyData.Dto
@model MeetUserDto
@{
    ViewBag.Title = "会议签到";
    Layout = "~/Views/Shared/_Index.cshtml";
}
<script src="~/Content/plupload/jquery-1.10.2.min.js"></script>
<script src="~/Content/plupload/plupload.full.min.js"></script>
<script src="~/Content/UI/js/select-ui.min.js"></script>
<script type="text/javascript">

    function queryParams() {
        return {
            CompanyName: $("#CompanyName").val(),
            Position: $("#Position").val(),
            UserName: $("#UserName").val(),
            PhoneNum: $("#PhoneNum").val(),
            ApplyStatus: $("#ApplyStatus").val(),
            HeadUrl: $("#headImage").attr("src"),
            Id: $("#Id").val()
        };
    }
    $(function () {
        fnUploadImg("updatefile-btn", "loadXls", "headImage");
        $(".select3").uedSelect({
            width: 300
        });
    })
    function fnUploadImg(btnId, containerId, imgId) {
        var uploader = new plupload.Uploader({ //实例化一个plupload上传对象
            browse_button: btnId,
            url: '@Url.Action("UploadProduct", "Visitor")',
            container: document.getElementById(containerId),
            flash_swf_url: '/Content/plupload/Moxie.swf',
            silverlight_xap_url: '/Content/plupload/Moxie.xap',
            filters: {
                mime_types: [ //只允许上传图片文件和rar压缩文件
                    { title: "Image files", extensions: "jpg,gif,png" }
                ],
                max_file_size: '20000kb', //最大只能上传20000kb的文件
                prevent_duplicates: false //不允许队列中存在重复文件
            },
            resize: {
                crop: false,
                quality: 60,
                preserve_headers: false
            },
            multipart_params: {}//参数
        });
        uploader.init(); //初始化
        uploader.bind('FilesAdded', function (uploader, files) {
            uploader.start();
        });
        uploader.bind('FileUploaded', function (uploader, file, responseObject) {
            var dom = document.getElementById(file.id)
            var response = $.parseJSON(responseObject.response);
            if (response.state == 1) {
                $("#" + imgId).attr("src", response.data);
            } else {
                layer.msg(response.message);
            }
        })
    }
</script>
<form id="form1">
    <div class="tools">
        <ul class="toolbar">
            <li class="click" onclick="fnSave()"><span><img src="../Content/UI/images/t02.png" /></span>保存</li>
        </ul>
    </div>
    <div class="formbody">
        <ul class="seachform">
            <li>
                <label>单位:</label><input value="@Model.CompanyName" type="text" class="dfinput" id="CompanyName" name="CompanyName" required />
            </li>
            <li>
                <label>职务:</label><input value="@Model.Position" type="text" class="dfinput" id="Position" name="Position" required />
            </li>


        </ul>
        <ul class="seachform">

            <li style="width:427px">
                <label>姓名:</label><input value="@Model.UserName" type="text" class="dfinput" id="UserName" name="UserName" required />
            </li>
            <li>
                <label>电话:</label><input value="@Model.PhoneNum" type="text" class="dfinput" id="PhoneNum" name="PhoneNum" required />
            </li>

        </ul>
        <ul class="seachform">
            <li style="width:427px">
                <label>审核状态:</label>
                <div class="vocation" style="width:300px">
                    <select class="select3" id="ApplyStatus">
                        <option value="0" selected>申请中</option>
                        <option value="1">已通过</option>
                    </select>
                </div>
            </li>
        </ul>
        <div id="loadXls">
            <ul class="forminfo">
                <li>
                    <label>&nbsp;&nbsp;&nbsp;头像:</label><img src="@Model.HeadUrl" height="200px" width="200px" id="headImage" />
                </li>
                <li>
                    <label>&nbsp;&nbsp;&nbsp;</label><a id="updatefile-btn" class="btn btn-primary">上传照片</a>
                </li>

            </ul>
        </div>
        <input type="hidden" id="Id" value="@Model.Id.ToString()" />
    </div>
</form>
<script type="text/javascript">
    if ('@Model.Id' != '00000000-0000-0000-0000-000000000000') {

        $("#ApplyStatus").val('@Model.ApplyStatus');
    }
    function fnSave() {
        $.post('@Url.Action("SaveCompany", "Visitor")', queryParams(), function (result) {
            if (result.state == 1) {
                layer.msg('操作成功');
                var index = parent.layer.getFrameIndex(window.name);
                parent.layer.close(index)
                parent.$("#table").bootstrapTable('refresh');
            }
            else {
                layer.msg(result.message);
            }
        })
    }

</script>
